'use strict';

const TOKEN_TIME_LABEL = 'Auth-Token-Time';
const TOKEN_TIME_VALUE = 24 * 60 * 60 * 1000;

// 设置登录时间
export const setTokenTime = () => {
  localStorage.setItem(TOKEN_TIME_LABEL, Date.now());
};

// 获取登录时间
export const getTokenTime = () => {
  return localStorage.getItem(TOKEN_TIME_LABEL);
};

// 登录是否过期
export const diffTokenTime = () => {
  const currentTime = Date.now();
  const tokenTime = getTokenTime();
  return currentTime - tokenTime > TOKEN_TIME_VALUE;
};
